﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

namespace HYSoft.Web
{
    public partial class BPsdwy1 : System.Web.UI.Page
    {

        //全局变量
        private string id = string.Empty;
        private string areano = string.Empty;
        private string cdbh = string.Empty;
        private int cdcgqsl = 0;
        private float[][] datas = new float[20][];
        private float[][] realdatas = new float[10][];
        private float[] length = new float[20];
        private int i = 0;
        private int rows = 0;
        //comm_data da = new comm_data();
        protected void Page_Load(object sender, EventArgs e)
        {
            ChartImage ci = new ChartImage(this.Page, "边坡深部位移图");

            id = Request.QueryString["id"];
            string sql = "  ljbp_sec_id=" + id + " ";
            DataSet ds = new BLL.bppmzbinfo().GetList(sql);

            DataTable dt = ds.Tables[0];
            if (dt.Rows.Count > 0)
            {
                cdbh = dt.Rows[0]["cdbh"].ToString();
                cdcgqsl = Convert.ToInt32(dt.Rows[0]["cdcgqsl"]);

                for (i = 0; i < 20; i++)
                {
                    length[i] = float.Parse(dt.Rows[0]["cdcgqclsd" + (i + 1).ToString()].ToString());
                }
            }
            for (i = 0; i < cdcgqsl; i++)
            {
                sql=" cdbh=" + cdbh + " and cdcgqbh=" + (i + 1).ToString() + " ";
                DataSet ds1 = new BLL.bpcddata().GetList(10, sql, " cldate DESC");
                dt = ds1.Tables[0];
               // dt = da.backdatatalbeselect("top 10 * ", "tb_bpcddata", " cdbh=" + cdbh + " and cdcgqbh=" + (i + 1).ToString() + " order by cldate DESC");
                rows = dt.Rows.Count;
                if (rows > 0)
                {
                    datas[i] = new float[rows];
                    for (int k = 0; k < rows; k++)
                    {
                        datas[i][k] = float.Parse(dt.Rows[k]["ljbpqcqxj_qx"].ToString());
                    }
                }
            }

            for (i = 0; i < rows; i++)
            {
                realdatas[i] = new float[cdcgqsl];
                for (int k = 0; k < cdcgqsl; k++)
                {
                    realdatas[i][k] = datas[k][i];
                }
            }
            //Response.Write("<script>alert('" + datas[0][3].ToString() + "')</script>");
            foreach (float[] arr in realdatas)
            {
                if (arr != null)
                {
                    ci.AddLine(arr, length);
                }
            }

            ci.Display();
        }
    }
}